<?php

require_once 'di/StandardDependencyInjector.php';

class CmsDependencyInjector extends StandardDependencyInjector
{
    private $applicationContext;

    /**
     *
     * @param AbstractApplicationContext $applicationContext
     * @param ServiceFactory $serviceFactory
     * @return CmsDependencyInjector
     */
    public function __construct(AbstractApplicationContext $applicationContext, ServiceFactory $serviceFactory)
    {
        $this->applicationContext = $applicationContext;
        $this->objectFactory = $serviceFactory;
        return $this;
    }

    /**
     *
     * @param string $className
     * @return mixed
     */
    protected function instance($className)
    {
        if ($className == 'FrontendApplicationContext' || $className == 'BackendApplicationContext') {
            return $this->applicationContext;
        }
        return $this->objectFactory->instance($className);
    }

}